<?php
use kartik\datecontrol\Module;

$params = require(__DIR__ . '/params.php');

$config = [
    'defaultRoute' => 'site/index1',
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'modules' => [
        'user' => [
            'class' => 'dektrium\user\Module',
            'admins' => ['admin'],
        ],
        'rbac' => [
            'class' => 'dektrium\rbac\Module',
        ],
        'api' => [
            'class' => 'app\api\Module',
    ],
//        'datecontrol' => [
//            'class' => 'kartik\datecontrol\Module',
//            // 需要显示的格式
//            'displaySettings' => [
//            //设置每种类型显示的格式
//            Module::FORMAT_DATE => 'yyyy-MM-dd',
//            Module::FORMAT_TIME => 'HH:mm:ss A',
//            Module::FORMAT_DATETIME => 'yyyy-MM-dd HH:mm:ss A',
//            ],
//
//            //需要保存的格式 （'date' 等同于 Module::FORMAT_DATE，其余类似 ）
//
//            'saveSettings' => [
//          //设置每种类型显示的格式
//                'date' => 'yyyy-MM-dd',
//                'time' => 'HH:mm:ss A',
//                'datetime' => 'yyyy-MM-dd HH:mm:ss A',
//            ],
//            // automatically use kartik\widgets for each of the above formats
//            'autoWidget' => true,
//        ],

    ],

    'components' => [
         'authManager' => [   //加入这两行
            'class' => 'yii\rbac\DbManager',
        ],
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '1111',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
//        'user' => [
//            'identityClass' => 'app\models\User',
//            'enableAutoLogin' => true,
//        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
       'mailer' => [
            'useFileTransport' => false, //这句一定有，false发送邮件，true只是生成邮件在runtime文件夹下，不发邮件
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.163.com', //使用163邮件服务器
                'username' => 'zfatgxu@163.com',
                'password' => 'zbustrainf', //此处隐去密码  
                'port' => '465', //端口一般都是465
                'encryption' => 'ssl', //协议一般都是ssl安全协议
            ],
            'messageConfig' => [
                'charset' => 'UTF-8',
                'from' => ['zfatgxu@163.com' => 'admin']
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
